#include<stdio.h>
#include <stdlib.h>
typedef struct Node{
	int date;
	struct Node *next;
}node,*Llist;
Llist build(int n){
	Llist p,head;
	head=(node*)malloc(sizeof(node));
	p=head;
	int x;
	printf("please input %d number:",n);//while(scanf("%d",&x) != EOF)
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		p->date=x;
		if(i==n-1){
			p->next=NULL;
			break;
		}
		p->next=(node*)malloc(sizeof(node));
		p=p->next;
	}
	return head;
}
void display(Llist head){
	Llist p;
	p=head;
	while(p){
		printf("%d ",p->date);
		p=p->next;
	}
	printf("\n");
}
Llist insert(Llist head,int i,int x){
	Llist p;p=head;
	Llist q=(node*)malloc(sizeof(node));
	q->date=x;
	if(i==0){
		q->next=p;
		head=q;
		return head;
	}
	for(int k=1;k<i;k++){
		p=p->next;
	}
	q->next=p->next;
	p->next=q;
	return head;
}
Llist dele(Llist head,int i){
	Llist p,q;p=head;
	if(i==1){
		head=p->next;
	//	free(p);
		return head;
	}
	for(int k=2;k<i;k++){
		p=p->next;
	}
	q=p->next;
	p->next=p->next->next;
	free(q);
	return head;
}
void main(){
	Llist list1;
	list1=build(10);
	display(list1);
	display(dele(list1,1));
	display(insert(list1,0,555));
	display(dele(list1,3));
}
//12 23 4 5 6 7 8 9 1 0